package gpx;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * @author Josef Vermach jr. Home
 * Class is responsible for Localization software in another languages. 
 */
public class Localization {
	/**
	 * Method gives text localized into specified language
	 * @param language - name of properties file 
	 * @param key - key word
	 * @return translated word
	 */
	public static String getString(String language, String key) {
		String s=null;
		try {
			ResourceBundle rb = ResourceBundle.getBundle(language.substring(0,8), new Locale(language.substring(9,14)));
			s = rb.getString(key);
		}
		catch (MissingResourceException e) {
			s = "No localization key.";
			System.out.println("LOG: Not found language file or missing file. "); 
		}
		return s;	
	}
	/**
	 * Method gives text localized into specified language
	 * @param language - name of properties file 
	 * @param key - key word 
	 * @param args - variable parametres of string
	 * @return translated text
	 */
	public static String getString(String language, String key, String[]args) {
		String s = null;
		try {
			ResourceBundle rb = ResourceBundle.getBundle(language.substring(0,8), new Locale(language.substring(9,14)));
			s = rb.getString(key);
			//TODO
		}
		catch (MissingResourceException e) {
			
		}
		return s;
		
	}
	
}
